package com.lyf.controller.user;

import com.lyf.mapper.admin.DishFlavorMapper;
import com.lyf.pojo.DishFlavor;
import com.lyf.result.Result;
import com.lyf.service.DishService;
import com.lyf.vo.DishVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


import java.util.List;

@Slf4j
@RestController("userDishController")
@RequestMapping("/user/dish")
@Api(tags = "用户端菜品接口")
public class DishController {
    @Autowired
    private DishService dishService;
    @Autowired
    private RedisTemplate redisTemplate;
    @Autowired
    private DishFlavorMapper dishFlavorMapper;

    @ApiOperation("根据分类id查询菜品")
    @GetMapping("list")
    @Cacheable(cacheNames = "dishCache", key = "#categoryId")
    public Result list(Long categoryId){
        log.info("根据分类id查询菜品：{}",categoryId);
        List<DishVO> list = dishService.list(categoryId);
        return Result.success(list);
    }

}
